<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>EQEmu</title>
    <link rel="stylesheet" type="text/css" href="style/style.css"/>
    <script src="scripts/jquery.js"></script>
    <script>
    <!--
    var locked = 0;
    var connected = 0;

    var idx = Math.floor((Math.random()*100000000));
    function GetStatusIdx() {
        return idx++;
    }

    function StatusTic() {
        $.getJSON("data/player_count.html"+"?idx="+GetStatusIdx(),
        function(data) {
            var elm = document.getElementById('pcount');
            elm.innerHTML = data.player_count;
        });

        $.getJSON("data/zone_count.html"+"?idx="+GetStatusIdx(),
        function(data) {
            var elm = document.getElementById('zcount');
            elm.innerHTML = data.zone_count;
        });

        $.getJSON("data/launcher_count.html"+"?idx="+GetStatusIdx(),
        function(data) {
            var elm = document.getElementById('lcount');
            elm.innerHTML = data.launcher_count;
        });

        $.getJSON("data/world_status.html"+"?idx="+GetStatusIdx(),
        function(data) {

            var elm = document.getElementById('lock_status');
            if(data.locked == 1) {
                elm.innerHTML = "locked";
                elm = document.getElementById('lock_link');
                elm.innerHTML = "Unlock World";
            } else {
                elm.innerHTML = "<b>NOT</b> locked";
                elm = document.getElementById('lock_link');
                elm.innerHTML = "Lock World";
            }

            elm = document.getElementById('conn_status');
            if(data.connected == 1) {
                elm.innerHTML = "connected";
                elm = document.getElementById('restart_id');
                elm.style.display = 'none';
            } else {
                elm.innerHTML = "<b>NOT</b> connected";
                elm = document.getElementById('restart_id');
                elm.style.display = 'inline';
            }

            locked = data.locked;
            connected = data.connected;
        });
    }

    function ToggleLock() {
        var action = "lock";
        if(locked == 1) {
            action = "unlock";
        }

        $.getJSON("actions/world_action.html?action=" + action+"&idx="+GetStatusIdx(),
        function(data) {

            var elm = document.getElementById('lock_status');
            if(data.locked == 1) {
                elm.innerHTML = "locked";
                elm = document.getElementById('lock_link');
                elm.innerHTML = "Unlock World";
            } else {
                elm.innerHTML = "<b>NOT</b> locked";
                elm = document.getElementById('lock_link');
                elm.innerHTML = "Lock World";
            }

            elm = document.getElementById('conn_status');
            if(data.connected == 1) {
                elm.innerHTML = "connected";
                elm = document.getElementById('restart_id');
                elm.style.display = 'none';
            } else {
                elm.innerHTML = "<b>NOT</b> connected";
                elm = document.getElementById('restart_id');
                elm.style.display = 'inline';
            }

            locked = data.locked;
            connected = data.connected;
        });
    }

    function Reconnect() {
        $.getJSON("actions/world_action.html?action=lsreconnect"+"&idx="+GetStatusIdx(),
        function(data) {

            var elm = document.getElementById('lock_status');
            if(data.locked == 1) {
                elm.innerHTML = "locked";
                elm = document.getElementById('lock_link');
                elm.innerHTML = "Unlock World";
            } else {
                elm.innerHTML = "<b>NOT</b> locked";
                elm = document.getElementById('lock_link');
                elm.innerHTML = "Lock World";
            }

            elm = document.getElementById('conn_status');
            if(data.connected == 1) {
                elm.innerHTML = "connected";
                elm = document.getElementById('restart_id');
                elm.style.display = 'none';
            } else {
                elm.innerHTML = "<b>NOT</b> connected";
                elm = document.getElementById('restart_id');
                elm.style.display = 'inline';
            }
            locked = data.locked;
            connected = data.connected;
        });
    }

    $(document).ready(function() {
        setInterval("StatusTic()", 4000);
    });
    -->
    </script>
</head>
<body>
    <div class="container">
        <?do("templates/scripts/menu.pl");?>
        <div id="main_content" class="main">
        <?
        my $zcount = $EQW->CountZones();
        my $lcount = $EQW->CountLaunchers(1);
        my $pcount = $EQW->CountPlayers();

        print "<table width='38%' class='styled_table' cellpadding='0' cellspacing='0' align='center'>";
        print "<tr>";
        print "<th>Zones Booted<th>";
        print "<th>Launchers Connected<th>";
        print "<th>Players Online<th>";
        print "</tr>";
        print "<tr>";
        print "<td><a href='zones.html' id='zcount'>$zcount</a><td>";
        print "<td><a href='launchers.html' id='lcount'>$lcount</a><td>";
        print "<td><a href='players.html' id='pcount'>$pcount</a><td>";
        print "</tr>";
        print "</table></br>";

        if($EQW->LSConnected()) {
            my $ls = $EQW->GetConfig("LoginHost");
            my $lsp = $EQW->GetConfig("LoginPort");
            $ls_str = "World is <span id='conn_status'>connected</span> to login server $ls:$lsp.</br><a style='display:none;' id='restart_id' href='javascript:void(0)' onclick='Reconnect()'>Restart Auto Reconnect</a></br>";
            print "<script><!--connected = 1;--></script>";
        } else {
            my $ls = $EQW->GetConfig("LoginHost");
            my $lsp = $EQW->GetConfig("LoginPort");
            $ls_str = "World is <span id='conn_status'><b>NOT</b> connected</span> to login server $ls:$lsp. </br><a id='restart_id' href='javascript:void(0)' onclick='Reconnect()'>Restart Auto Reconnect</a></br>";
        }
        print "<div width='38%' align='center'>";
        print "$ls_str";
        print "</div></br>";

        if($EQW->GetConfig("Locked") eq "true") {
            $locked_str =  "World is <span id='lock_status'>locked</span>. <a href='javascript:void(0)' id='lock_link' onclick='ToggleLock()'>Unlock World</a>.<br>";
            print "<script><!--locked = 1;--></script>";
        } else {
            $locked_str =  "World is <span id='lock_status'><b>NOT</b> locked</span>. <a href='javascript:void(0)' id='lock_link' onclick='ToggleLock()'>Lock World</a>.<br>";
        }

        print "<div width='38%' align='center'>";
        print "$locked_str";
        print "</div>";
        ?>
        </div>
    </div>
    <div class="footer">
        &copy 2012 EQEmu. All rights reserved.
    </div>
</body>
</html>
